VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmIntlDIMs 
   BackColor       =   &H00FFFFFF&
   Caption         =   "International MPS Dimensions"
   ClientHeight    =   5175
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5655
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   ScaleHeight     =   5175
   ScaleWidth      =   5655
   StartUpPosition =   1  'CenterOwner
   Begin VB.ComboBox cboBoxName 
      Height          =   315
      Left            =   3720
      TabIndex        =   5
      Text            =   "Combo1"
      Top             =   1200
      Width           =   1335
   End
   Begin VB.ComboBox f1116 
      Height          =   315
      ItemData        =   "frmIntlDIMs.frx":0000
      Left            =   2040
      List            =   "frmIntlDIMs.frx":000A
      TabIndex        =   6
      Text            =   "Combo1"
      Top             =   1560
      Width           =   1575
   End
   Begin VB.CommandButton cmdDeleteAll 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "Delete All"
      Height          =   315
      Left            =   1320
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   8
      Top             =   4680
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdAddIntlDIMs 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "Add To Shipment"
      Height          =   315
      Left            =   2040
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   7
      Top             =   1920
      UseMaskColor    =   -1  'True
      Width           =   1455
   End
   Begin VB.CommandButton cmdClose 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "Close"
      Height          =   315
      Left            =   3120
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   9
      Top             =   4680
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.TextBox f57 
      Height          =   315
      Left            =   2040
      TabIndex        =   2
      Top             =   1200
      Width           =   375
   End
   Begin VB.TextBox f58 
      Height          =   315
      Left            =   2640
      TabIndex        =   3
      Top             =   1200
      Width           =   375
   End
   Begin VB.TextBox f59 
      Height          =   315
      Left            =   3240
      TabIndex        =   4
      Top             =   1200
      Width           =   375
   End
   Begin VB.TextBox txtNoPkgs 
      Height          =   315
      Left            =   2040
      TabIndex        =   1
      Text            =   "1"
      Top             =   840
      Width           =   735
   End
   Begin VB.TextBox f1 
      Height          =   315
      Left            =   2040
      TabIndex        =   0
      Top             =   480
      Width           =   3015
   End
   Begin MSDataGridLib.DataGrid grdIntlDIMs 
      Height          =   2055
      Left            =   120
      TabIndex        =   17
      TabStop         =   0   'False
      ToolTipText     =   "To Delete a Commodity, highlight the row and press the Delete key."
      Top             =   2400
      Width           =   5415
      _ExtentX        =   9551
      _ExtentY        =   3625
      _Version        =   393216
      ForeColor       =   0
      HeadLines       =   2
      RowHeight       =   15
      TabAction       =   2
      WrapCellPointer =   -1  'True
      AllowAddNew     =   -1  'True
      AllowDelete     =   -1  'True
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "Total Packages: 0"
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.Label Label17 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      Caption         =   " Units:"
      Height          =   255
      Index           =   1
      Left            =   960
      TabIndex        =   18
      Top             =   1620
      Width           =   975
   End
   Begin VB.Line Line1 
      BorderColor     =   &H000080FF&
      BorderWidth     =   2
      X1              =   240
      X2              =   5400
      Y1              =   120
      Y2              =   120
   End
   Begin VB.Label lblPackage 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Add International Package Dimensions"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   255
      Left            =   240
      TabIndex        =   16
      Top             =   135
      Width           =   3495
   End
   Begin VB.Label Label73 
      Alignment       =   2  'Center
      BackColor       =   &H00FFFFFF&
      Caption         =   "x"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   0
      Left            =   3000
      TabIndex        =   15
      Top             =   1230
      Width           =   255
   End
   Begin VB.Label Label24 
      Alignment       =   2  'Center
      BackColor       =   &H00FFFFFF&
      Caption         =   "x"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   0
      Left            =   2400
      TabIndex        =   14
      Top             =   1230
      Width           =   255
   End
   Begin VB.Label Label17 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      Caption         =   " Dimensions:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   0
      Left            =   600
      TabIndex        =   13
      Top             =   1260
      Width           =   1335
   End
   Begin VB.Label Label16 
      BackColor       =   &H00FFFFFF&
      Caption         =   "00 x 00 x 00 in."
      ForeColor       =   &H000080FF&
      Height          =   255
      Index           =   0
      Left            =   3720
      TabIndex        =   12
      Top             =   1260
      Width           =   1095
   End
   Begin VB.Label lblNoPkgs 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      Caption         =   "# of Pkgs to Add:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   1
      Left            =   240
      TabIndex        =   11
      Top             =   900
      Width           =   1695
   End
   Begin VB.Label Label50 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      Caption         =   "Order ID:"
      Height          =   255
      Left            =   960
      TabIndex        =   10
      Top             =   540
      Width           =   975
   End
End
Attribute VB_Name = "frmIntlDIMs"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public WithEvents g_rsIntlDIMs As ADODB.Recordset
Attribute g_rsIntlDIMs.VB_VarHelpID = -1
'---------------------------------------------------------------------------------------
' Procedure : cboBoxName_LostFocus()
' DateTime  : 7/7/2004
' Purpose   : DIMs combo. Called on LostFocus to add or update box dims
'---------------------------------------------------------------------------------------
'
Private Sub cboBoxName_LostFocus()
    If cboBoxName <> "" And f57 <> "" And f58 <> "" And f59 <> "" Then
        Call SaveBoxDIMs(cboBoxName, f57, f58, f59)
        Call LoadBoxDIMsCombos(frmShip.cboBoxName(0))
        Call LoadBoxDIMsCombos(frmShip.cboBoxName(1))
        Call LoadBoxDIMsCombos(frmMPS.cboBoxName)
        Call LoadBoxDIMsCombos(cboBoxName, cboBoxName)
    End If
End Sub

'---------------------------------------------------------------------------------------
' Procedure : cmdClose_Click()
' DateTime  : 4/7/2004
' Purpose   : Close clicked, hide the form
'---------------------------------------------------------------------------------------
'
Private Sub cmdClose_Click()
    g_str1116 = f1116
    frmShip.f24.SetFocus
    Me.Hide
End Sub

'---------------------------------------------------------------------------------------
' Procedure : cmdDeleteAll_Click()
' DateTime  : 3/19/2004
' Purpose   : Verifes user wished to delete all pieces in a shipment and if yes, calls
'           : DeleteMPSFromMDB and UpdateMPSGrid.
'---------------------------------------------------------------------------------------
'
Private Sub cmdDeleteAll_Click()
    Dim intRet As Integer

    intRet = MsgBox("Are you sure you wish to delete all DIM items in this shipment?", vbYesNo, "Delete All")
    If intRet = vbYes Then
        DeleteAllIntlDIMsFromMDB (f1)
        UpdateIntlDIMsGrid (f1)
    End If
End Sub
'---------------------------------------------------------------------------------------
' Procedure : cmdAddIntlDIMs_Click()
' DateTime  : 3/19/2004
' Purpose   : Adds a record to the DomMPS table for # of pkgs entered then clears some of
'           : the text fields and call UpdateMPSGrid
'---------------------------------------------------------------------------------------
'
Private Sub cmdAddIntlDIMs_Click()
    Dim i As Integer
    
    On Error GoTo EH
    g_strErrorLocation = "frmIntlDIMs:cmdAddIntlDIMs_Click"
    
    'Check to ensure # of pkgs is entered
    If Val(txtNoPkgs) < 1 Then
        MsgBox "Please enter the # of Pkgs to Add.", vbExclamation, "Intl DIMs Error"
        txtNoPkgs.SetFocus
        Exit Sub
    End If
    
    'Loop through # of pkgs and add the data to the database
    For i = 1 To txtNoPkgs
        If AddIntlDIMsToMDB() < 1 Then
            'Error!
            MsgBox "Package NOT added to database, please try again.", vbApplicationModal Or vbCritical
        End If
    Next i
    
    'Clear some of the fields
    f57 = ""
    f58 = ""
    f59 = ""
    txtNoPkgs = "1"
    
    'Update the DataGrid Control
    UpdateIntlDIMsGrid (f1)
    
    Exit Sub

EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
End Sub

'---------------------------------------------------------------------------------------
' Procedure : f1_LostFocus()
' DateTime  : 3/16/2004
' Purpose   : Update datagrid if Order ID is different than the one on frmShip.
'---------------------------------------------------------------------------------------
'
Private Sub f1_LostFocus()
    If f1 <> frmShip.f1 Then
        Call UpdateIntlDIMsGrid(f1)
    End If
End Sub
'---------------------------------------------------------------------------------------
' Procedure : f57_Change, f58_Change, f59_Change()
' DateTime  : 4/7/2004
' Purpose   : DIM fields are numeric only with max length of 3
'---------------------------------------------------------------------------------------
'
Private Sub f57_Change()
    Call NumericOnly(f57, False)
    Call CheckLength(f57, 3)
End Sub

Private Sub f58_Change()
    Call NumericOnly(f58, False)
    Call CheckLength(f58, 3)
End Sub
Private Sub f59_Change()
    Call NumericOnly(f59, False)
    Call CheckLength(f59, 3)
End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_Load()
' DateTime  : 4/7/2004
' Purpose   : Instantiate recordset
'---------------------------------------------------------------------------------------
'
Private Sub Form_Load()
    Set g_rsIntlDIMs = New ADODB.Recordset
End Sub

'---------------------------------------------------------------------------------------
' Procedure : Form_Activate()
' DateTime  : 4/7/2004
' Purpose   : Runs when IntlDIMs form is active form on screen. Copies default values from
'             form ship and updates datagrid.
'Calls:     : UpdateMPSGrid
'---------------------------------------------------------------------------------------
'
Private Sub Form_Activate()
    On Error GoTo EH
    g_strErrorLocation = "frmIntlDIMs:Form_Activate"
    
    'Show DIMs combo if there are items in it
    If cboBoxName.ListCount > 0 Then
        cboBoxName.Visible = True
    Else
        cboBoxName.Visible = False
    End If
    
    f1 = frmShip.f1
    
    'Set default to Inches
    f1116.ListIndex = 0
    
    'Update the Datagrid just in case
    Call UpdateIntlDIMsGrid(f1)
    
    f1.SetFocus
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_KeyDown()
' DateTime  : 2/17/2005
' Purpose   : Enter key pressed sends a TAB to move to next field
'---------------------------------------------------------------------------------------
'
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Not TypeOf Me.ActiveControl Is CommandButton Then
        If Shift = 0 And KeyCode = 13 Then
            SendKeys "{TAB}"
        End If
    End If
End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_Unload()
' DateTime  : 4/7/2004
' Purpose   : Kills objects
'---------------------------------------------------------------------------------------
'
Private Sub Form_Unload(Cancel As Integer)
    Set grdIntlDIMs.DataSource = Nothing
    Set g_rsIntlDIMs = Nothing
End Sub
'---------------------------------------------------------------------------------------
' Procedure : UpdateIntlDIMsGrid()
' DateTime  : 4/7/2004
' Purpose   : Update the datagrid for given OrderID. Also assign column captions.
' Call from :
'---------------------------------------------------------------------------------------
'
Public Sub UpdateIntlDIMsGrid(ByVal strOrderID As String)
    Dim strSQL As String
    
    On Error GoTo EH
    g_strErrorLocation = "frmIntlMPS:UpdateIntlDIMsGrid"
    
    'Build and open the recordset
    strSQL = "SELECT f1, f57, f58, f59 FROM IntlDIMs WHERE f1 = '" & strOrderID & "'"
    If g_rsIntlDIMs.State = adStateOpen Then
        g_rsIntlDIMs.Close
    End If
    g_rsIntlDIMs.Open strSQL, g_connFSMSClient, adOpenStatic, adLockOptimistic

    Set grdIntlDIMs.DataSource = g_rsIntlDIMs
    With grdIntlDIMs
        .ClearFields
        .ReBind
        .Columns(0).Caption = "Order ID"
        .Columns(1).Caption = "H"
        .Columns(2).Caption = "W"
        .Columns(3).Caption = "L"
        .Caption = "Total Pieces: " & Str(g_rsIntlDIMs.RecordCount)
    End With
    If g_rsIntlDIMs.RecordCount > 0 Then
        frmShip.f116 = Str(g_rsIntlDIMs.RecordCount)
    Else
        frmShip.f116 = 1
    End If
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
     
End Sub

'---------------------------------------------------------------------------------------
' Procedure : AddMPSToMDB()
' DateTime  : 4/7/2004
' Purpose   : Adds a record to the IntlDIMs database and returns the number of
'             records affected...usually '1'.
'---------------------------------------------------------------------------------------
'
Public Function AddIntlDIMsToMDB() As Long
    
    Dim strSQL As String
    
    On Error GoTo EH
    g_strErrorLocation = "frmIntlDIMs:AddIntlDIMsToMDB"
    
    'Set the return value to zero in case of a runtime error
    AddIntlDIMsToMDB = 0
    
    'Build and execute the SQL statement
    strSQL = "INSERT into IntlDIMs VALUES (" & SingleQuotes(f1) & ","
    strSQL = strSQL & SingleQuotes(f57) & ","
    strSQL = strSQL & SingleQuotes(f58) & ","
    strSQL = strSQL & SingleQuotes(f59) & ","
    strSQL = strSQL & SingleQuotes(Format(Date, "YYYYMMDD")) & ")"
    
    g_connFSMSClient.Execute strSQL, AddIntlDIMsToMDB

    Exit Function
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
End Function

'---------------------------------------------------------------------------------------
' Procedure : grdIntlDIMs_AfterDelete()
' DateTime  : 4/7/2004
' Purpose   : Update recordcount after a record is deleted.
'---------------------------------------------------------------------------------------
'
Private Sub grdIntlDIMs_AfterDelete()
    Dim rsQuery As String
    Dim rsIntlDIMSCount
    
    On Error GoTo EH
    g_strErrorLocation = "frmMPS:grdIntlDIMs_AfterDelete"

    Set rsIntlDIMSCount = New ADODB.Recordset
    rsQuery = "SELECT * FROM IntlDIMs WHERE f1 = '" & f1 & "'"
    rsIntlDIMSCount.Open rsQuery, g_connFSMSClient, adOpenStatic, adLockOptimistic
    grdIntlDIMs.Caption = "Total Commodities: " & Str(rsIntlDIMSCount.RecordCount - 1)

Release:
    If rsIntlDIMSCount.State = adStateOpen Then
        rsIntlDIMSCount.Close
    End If
    Set rsIntlDIMSCount = Nothing
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
    Resume Release
    
End Sub
'---------------------------------------------------------------------------------------
' Procedure : grdIntlDIMs_BeforeDelete()
' DateTime  : 3/19/2004
' Purpose   : Verify user wishes to delete a record in the MPS grid.
'---------------------------------------------------------------------------------------
'
Private Sub grdIntlDIMs_BeforeDelete(Cancel As Integer)
    Dim intResult As Integer
    
    intResult = MsgBox("Are you sure that you want to delete selected record?", vbYesNo, "Delete Confirmation")
   
    If intResult = vbNo Then
        Cancel = True
    End If

End Sub
'---------------------------------------------------------------------------------------
' Procedure : grdIntlDIMs_AfterColUpdate()
' DateTime  : 7/15/2004
' Modified  : 8/11/2004
' Change    : Added a check for Null before setting the bookmark. This allows records
'             to be added. Also added error handling.
' Purpose   : This commits the changes immediately after a column has been updated.
'             This keeps users from getting "Operation not allowed in this context" error.
'---------------------------------------------------------------------------------------
'
Private Sub grdIntlDIMs_AfterColUpdate(ByVal ColIndex As Integer)
    On Error GoTo EH
    g_strErrorLocation = "frmIntlDIMs:grdIntlDIMs_AfterColUpdate"
    
    If grdIntlDIMs.Bookmark >= 0 Then
        grdIntlDIMs.Bookmark = grdIntlDIMs.Bookmark
    End If
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub
'---------------------------------------------------------------------------------------
' Procedure : DeleteAllIntlDIMsFromMDB()
' DateTime  : 4/7/2004
' Purpose   : Deletes all pieces in IntlDIMs for passed OrderID
'---------------------------------------------------------------------------------------
'
Public Function DeleteAllIntlDIMsFromMDB(strKey As String) As Long
    
    Dim strSQL As String
    
    On Error GoTo EH
    g_strErrorLocation = "frmIntlDIMs:DeleteAllIntlDIMsFromMDB"
    
    'Set the return value in case of a run time error
    DeleteAllIntlDIMsFromMDB = 0
    
    'Build and execute the delete query
    strSQL = "DELETE FROM IntlDIMs WHERE f1= '" & strKey & "'"
    g_connFSMSClient.Execute strSQL, DeleteAllIntlDIMsFromMDB
    
    Exit Function
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Function
'---------------------------------------------------------------------------------------
' Procedure : txtNoPkgs_Change()
' DateTime  : 4/7/2004
' Purpose   : # of pkgs is numeric only
'---------------------------------------------------------------------------------------
'
Private Sub txtNoPkgs_Change()
    Call NumericOnly(txtNoPkgs, False)
End Sub

Private Sub cboBoxName_Click()
    Dim rsBoxDIMs As New ADODB.Recordset
    Dim strQuery As String
    strQuery = "SELECT * FROM Dimensions WHERE BoxName = " & SingleQuotes(cboBoxName)
    rsBoxDIMs.Open strQuery, g_connFSMSClient, adOpenStatic, adLockOptimistic
    
    f57 = rsBoxDIMs!g_str57
    f58 = rsBoxDIMs!g_str58
    f59 = rsBoxDIMs!g_str59
    
Release:

    If rsBoxDIMs.State = adStateOpen Then
        rsBoxDIMs.Close
    End If
    Set rsBoxDIMs = Nothing
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
    Resume Release
    
End Sub

